package junit.utils;

import io.jboot.db.model.Columns;
import io.jpress.commons.utils.SqlUtils;
import org.junit.Assert;
import org.junit.Test;

public class SqlUtilsTester {

    @Test
    public void testBuildInSqlPara() {

        //构建结果
        String sqlPart = SqlUtils.buildInSqlPara(1, 2, 3);
        Assert.assertEquals(sqlPart, "(1, 2, 3)");


        //错误的参数必抛出异常
        Assert.assertThrows(IllegalArgumentException.class, () -> SqlUtils.buildInSqlPara("a", 1, 2));

    }


    @Test
    public void testToWhereSql() {

        Columns columns = Columns.create();
        columns.eq("id", 1);

        //构建结果
        String sqlPart = SqlUtils.toWhereSql(columns);
        Assert.assertEquals(sqlPart, " WHERE  id  = ?");
    }


}
